package com.itxiaoxiong.chat.mapper;

import com.itxiaoxiong.chat.pojo.User;
import com.itxiaoxiong.chat.pojo.UserAccount;
import com.itxiaoxiong.chat.pojo.UserTT;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {
    /*
    查询用户
     */
/*
    @Select("select * from user")
    List<UserTT> list();
*/

    /*
    根据账号注销用户
     */
/*    @Delete("delete from user where account = #{account}")
    void deleteByAccount(String account);*/
    @Delete("delete from user where account = #{account}")
    int deleteByAccount(String account);


    /*
    注册用户
     */
    @Insert("insert into user(username, password, image, account) values (#{username}, #{password}, #{image}, #{account})")
    void insert(User user);

    @Select("select * from user where username = #{username}")
    User findByUsername(String username);

    /*
    修改用户信息
     */
    @Update("update user set username = #{username}, password = #{password}, image = #{image} where account = #{account}")
    void update(User user);

    /*
    根据id查询
     */
    @Select("select * from user where id = #{id}")
    User listUserName(@Param("id") Integer id);


    /*
    根据account和id进行查询
     */
    @Select("select * from user where(id = #{id} and account = #{account})")
    User accountUser(UserAccount ua);
}
